/**
 * 
 */
package org.statewalker.validator.impl;

import org.statewalker.validator.AbstractValidator;
import org.statewalker.validator.IParseKey;
import org.statewalker.validator.IParseState;
import org.statewalker.validator.IParseToken;

public class Validator extends AbstractValidator<IParseState, IParseToken> {

    private IdGenerator fIdGenerator;

    private IdGenerator getIdGenerator() {
        if (fIdGenerator == null)
            fIdGenerator = new IdGenerator();
        return fIdGenerator;
    }

    @Override
    public IParseKey newParseKey(String name) {
        return new ParseKey(getIdGenerator(), name);
    }

    @Override
    protected IParseState newParseState(IParseToken token, IParseKey targetKey) {
        return new ParseState(targetKey);
    }

    @Override
    protected IParseToken newParseToken(IParseKey key, boolean open) {
        return new ParseToken(key, open);
    }

}